app.controller("home",function($scope,$http,$rootScope,$uibModal){
	$scope.pages={}
	/**
	 * 栏目
	 * @param {Object} val
	 * @param {Object} name
	 */
	$scope.getPage=function(val,name,pages){
		sessionStorage.setItem("Name",name||'s');
		sessionStorage.setItem("page",val);
		val=sessionStorage.getItem("page")
		$scope.page=sessionStorage.getItem("page")
		if(pages!=null){
			$scope.pages=pages
			$scope.pages[val]=!$scope.pages[val]
			sessionStorage.setItem("pages",JSON.stringify($scope.pages));
			angular.forEach(pages,function(o,value){
				if(val!=value&sessionStorage.getItem("Name")=='s'){
					$scope.pages[value]=false
				}
			})
		}else{
			$scope.pages[val]=!$scope.pages[val]
			sessionStorage.setItem("pages",JSON.stringify($scope.pages));
			angular.forEach($scope.pages,function(o,value){
				if(val!=value&sessionStorage.getItem("Name")=='s'){
					$scope.pages[value]=false
				}
			})
		}
		console.log($scope.pages)
		
		
	}
	
	$scope.getPage(sessionStorage.getItem("page"),sessionStorage.getItem("Name"),JSON.parse(sessionStorage.getItem("pages")))
	/**
	 * 怎删改查提示
	 * @param {Object} url
	 */
	$rootScope.open = function(val) {
		setTimeout(function() {
			$uibModal.open({ //模态框
				animation: true,
				templateUrl: "myModalAddFail.html",
				size: 'sm',
				controller: function($uibModalInstance, $timeout,$scope) {
					$scope.val=val
					$timeout(function() {
						$uibModalInstance.close();
					}, 800)
				}
			})
		}, 400)
	}
		
	
})
